from django.contrib import admin
from django.urls import path, include, register_converter
from rest_framework.routers import DefaultRouter
from rest_framework_jwt.views import obtain_jwt_token
# from .views import login
from apps.meiduo_admin.login import admin_jwt_token
from apps.meiduo_admin.serializers.image import ImageSeriazlier
from apps.meiduo_admin.view import permission
from apps.meiduo_admin.view.count_views import UserDailyActiveCountView, UserDailyOrderCountView, UserMonthCountView, \
    UserDayCountView
from apps.meiduo_admin.view.image import ImageView, SKUView
from apps.meiduo_admin.view.permission import PermissionView, ContentTypeAPIView, GroupView, GroupSimpleAPIView, \
    AdminView, AdminSimpleAPIView
from apps.meiduo_admin.view.sku_views import SKUModelViewSet, SKUCategoriesView, GoodsSimpleView, GoodsSpecView
from apps.meiduo_admin.view.user_views import UserListView
from utils.converters import UsernameConverter, MobileConverter, UUIDConverter

urlpatterns = [
    # path('authorlzations/', obtain_jwt_token),
    # 登录
    path(r'authorizations/', admin_jwt_token),
    # 日活用户
    path(r'statistical/day_active/', UserDailyActiveCountView.as_view()),
    # 日下单用户
    path(r'statistical/day_orders/', UserDailyOrderCountView.as_view()),
    # 月增用户统计
    path(r'statistical/month_increment/', UserMonthCountView.as_view()),
    # 日增用户统计
    path(r'statistical/day_increment/', UserDayCountView.as_view()),
    # 获取所有用户
    path(r'users/', UserListView.as_view()),
    # 获取所有sku数据 id和name 用来添加图片
    path('skus/simple/', SKUView.as_view()),
    # 获取三级分类
    path('skus/categories/', SKUCategoriesView.as_view()),
    # 获取spu数据
    path('goods/simple/', GoodsSimpleView.as_view()),
    # 获取SPU商品规格信息
    path('goods/<int:pk>/specs/', GoodsSpecView.as_view()),
    # 更新权限数据
    path('permission/content_types/', ContentTypeAPIView.as_view()),
    # 获取简单权限，为了添加组的时候显示列表
    path('permission/simple/', GroupSimpleAPIView.as_view()),
    # 添加管理员的时候 获取组的数据
    path('permission/groups/simple/', AdminSimpleAPIView.as_view()),

]

# 创建router实例
router = DefaultRouter()
# 注册路由
router.register(r'skus/images', ImageView, basename='image')
# sku管理
router.register(r'skus', SKUModelViewSet, basename='sku')
# 获取权限数据
router.register(r'permission/perms', PermissionView, basename='perms')
# 组管理
router.register(r'permission/groups', GroupView, basename='group')
# 管理员管理
router.register(r'permission/admins', AdminView, basename='admin')

# 将router生成的路由追加到urlpatterns中
urlpatterns += router.urls
